package product

import (
	"context"

	"github.com/sagoo-cloud/sagooiot/internal/dao"
	"github.com/sagoo-cloud/sagooiot/internal/model"
	"github.com/sagoo-cloud/sagooiot/internal/service"
)

type sProductUpgradeInfo struct{}

func sProductUpgradeInfoNew() *sProductUpgradeInfo {
	return &sProductUpgradeInfo{}
}

func init() {
	service.RegisterProductUpgradeInfo(sProductUpgradeInfoNew())
}

// GetUpgradeInfoList 获取列表数据
func (s *sProductUpgradeInfo) GetUpgradeInfoList(ctx context.Context, in *model.GetUpgradeInfoListInput) (total, page int, list []*model.UpgradeInfoOutput, err error) {

	return
}

// GetUpgradeInfoById 获取指定ID数据
func (s *sProductUpgradeInfo) GetUpgradeInfoById(ctx context.Context, id int) (out *model.UpgradeInfoOutput, err error) {
	err = dao.UpgradeInfo.Ctx(ctx).Where(dao.UpgradeInfo.Columns().Id, id).Scan(&out)
	return
}

// AddUpgradeInfo 添加数据
func (s *sProductUpgradeInfo) AddUpgradeInfo(ctx context.Context, in model.UpgradeInfoAddInput) (err error) {
	_, err = dao.UpgradeInfo.Ctx(ctx).Insert(in)
	return
}

// EditUpgradeInfo 修改数据
func (s *sProductUpgradeInfo) EditUpgradeInfo(ctx context.Context, in model.UpgradeInfoEditInput) (err error) {
	dao.UpgradeInfo.Ctx(ctx).FieldsEx(dao.UpgradeInfo.Columns().Id).Where(dao.UpgradeInfo.Columns().Id, in.Id).Update(in)
	return
}

// DeleteUpgradeInfo 删除数据
func (s *sProductUpgradeInfo) DeleteUpgradeInfo(ctx context.Context, Ids []int) (err error) {
	_, err = dao.UpgradeInfo.Ctx(ctx).Delete(dao.UpgradeInfo.Columns().Id+" in (?)", Ids)
	return
}
